/*
 *  crypto.h - Crypto Functions
 *  Copyright (c) 2005 Derek Ingrouville (dergro@users.sourceforge.net)
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef _CRYPTO_H
#define _CRYPTO_H

#include <openssl/evp.h>

typedef enum _DigestType
{
    DIGEST_MD5,
	DIGEST_SHA1
} DigestType;

typedef struct _Digest
{
	EVP_MD_CTX mdctx;	/* Digest context */
	const EVP_MD *md;	/* The digest being used */
} Digest;

Digest *digest_new (DigestType type);
void digest_append (Digest *digest, const void *buf, size_t size);
void digest_finish (Digest *digest, unsigned char *buf, unsigned int *size);
char *digest_final_str (Digest *digest);
void digest_free (Digest *digest);

char *md5_hash_str (const char *format, ...);
char *sha1_hash_str (const char *format, ...);

char *base64_encode (void *buf, unsigned int size);
void *base64_decode (char *buf, size_t size);

#endif /* _CRYPTO_H */
